package com.qifan.energy.widget.dialog;

import android.content.Context;

import androidx.appcompat.app.AppCompatDialog;

import java.util.ArrayList;

public class LoadingUtils {

    /* 缓存 */
    private static final ArrayList<AppCompatDialog> LOADERS = new ArrayList<>();

    /* 显示指示器 */
    public static void show(Context context){
        LoadingDialog dialog = LoadingDialog.getInstance(context);
        LOADERS.add(dialog);
        dialog.show();
    }

    /* 隐藏指示器 */
    public static void hide(){
        for (AppCompatDialog dialog : LOADERS) {
            if (dialog != null) {
                if (dialog.isShowing()) {
                    dialog.cancel();
                }
            }
        }
        LOADERS.clear();
    }
}
